﻿using System;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;

namespace GIMS.GUI.Options
{
    public class OptionsWindowViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

        public string IMPath
        {
            get { return ConfigurationManager.AppSettings["IMPath"]; }

            set
            {
                config.AppSettings.Settings.Remove("IMPath");
                config.AppSettings.Settings.Add("IMPath", value);
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
                OnPropertyChanged("IMPath");
            }
        }

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
